import * as user from '@/api/user.js'
	export default {
		data() {
			return {
				Type: uni.getStorageSync('Type'),
				from:{}
			};
		},
		onLoad() {
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			// 获取绑定手机号
			getUserInfo() {
				user.getUserInfo({
					type: this.Type
				}).then(res => {
					this. from= res.data
					this.Type = uni.getStorageSync('Type')
				})
			},
			tongzhi(){
				this.$tools.toOpenNotificationSettings()
			},
			agreementBnt() {
				this.$tools.navigate('/pages/login/agreement/index?name=wx_protocol')
			},
			yinsitBnt(){
				this.$tools.navigate('/pages/login/agreement/index?name=yinsixieyi')
			},
			//绑定手机号
			bindMobile(){
				this.$tools.navigate('/pages/user/setting/bindMobile/index')
			},
			//退出登录
			deleteLogin() {
				let that = this
				uni.showModal({
				    title: '提示',
				    content: '确定退出登录吗?',
				    success:(res)=> {
						if (res.confirm) {
							that.disconnect()
							uni.removeStorageSync('token');
							uni.removeStorageSync('userInfo');
							// this.$tools.navigate('/pages/home/index',true)
							uni.reLaunch({
								url:'/pages/home/index'
							})
						}
				    }
				})
			},
			memberOut(){
					let that = this
				uni.showModal({
					title: '注销用户',
					content: '90天内再次登录可撤销注销操作,您确定注销您的用户吗?',
					confirmText:'注销',
					success: function (res) {
						if (res.confirm) {
							user.memberOut().then(res=>{
								that.disconnect()
								uni.clearStorage();
								uni.clearStorageSync();
								// this.$tools.toast('撤回成功')
							})
						} else if (res.cancel) {
							that.$tools.toast('取消注销')
						}
					}
				});
			},
			disconnect() { //断开链接
				if(this.goEasy.getConnectionStatus() != 'disconnected'){
					this.goEasy.disconnect({
						onSuccess: function() {
							console.log('断开成功')
							uni.removeStorageSync('currentUser');
						},
						onFailed: function(error) {
							// 务必确保断开成功才允许客户退出应用，否则有可能会收到上个用户的消息。
			
							console.log('断开失败', error);
			
						}
					});
				}
			
			},
		}
	}